<html>
	<head>
		<title>
			arcanoid - survival mode
		</title>
		
		<script src = "logic.js"> </script>
		<script src = "render.js"> </script>
		
		
		
		<script>
			var inter;
			
			function onInterval(){
				for(i=0;i<speed;i++){
					moveBall();
					drawRoom();
				}
				score+=1;
				topValue+=0.1;
				if (pl_add)
					pl_w+=0.25;
				else
					pl_w-=0.25;
				if(pl_w==15)
					pl_add=true;
				if(pl_w==100)
					pl_add=false;
				b_r+=0.001;
				speed+=0.002;
				printInfo({"score":score});
				if (topValue+b_r+speed+1==HEIGHT)
					gameOver('You Win!!!');
			}
			
			function onClickCanvas(){
				if(!started)
					inter=setInterval(onInterval,10);
				started=true;
			}
			
			function movePlatform(evt){
				pl_x=evt.clientX;
				if (!(pl_x<WIDTH-pl_w))
					pl_x=WIDTH-pl_w;
				if (!started){
					b_x=pl_x+pl_w/2;
					drawRoom();
				}
			}

			function newGame() {
				if(started)
					clearInterval(inter);
				initGame();
				drawRoom();
				printInfo({"score":Math.ceil(score)});
			}

			function start(){
				initGraph();
				newGame();
			}
			
			
			function printInfo(info) {
				var d = document.getElementById('info');
				d.innerHTML = "";
				for(var k in info) {
					d.innerHTML = d.innerHTML + "<p>" + k + ": " + info[k] + "</p>";
				}
			}
		
		</script>
		
		
		
		<style>
			canvas{
				position: fixed;
				top: 0px;
				left: 0px;
				border:solid black 1px;
				background-color:#222222
			}
			#interface{
				position: fixed;
				top: 0px;
				left: 305px;
			}
		</style>
		
		<meta HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8"/>
	</head>
	
	<body onload="start()">
		<canvas id="myCanvas" width="300" height="450" onclick = "onClickCanvas()" onMouseMove = movePlatform(event)>
		</canvas>
		
		<div id = "interface">
			<input type = "button" value = "New Game" onclick = "newGame()">
			<div id = "info"> </div>
		</div>
		<div id="about" style="margin:5em 1em 0 300px">
		<p>
		<hr>
			Разработал Шатов Дмитрий.<br/>
			<a href="http://schoolmit.ru">ШМИТ</a>. Январь, 2011.<br>
			<a href="http://www.progschool.ru/index.php/ШП/Portfolio/SchoolMIT2011#.D0.A8.D0.B0.D1.82.D0.BE.D0.B2_.D0.94.D0.BC.D0.B8.D1.82.D1.80.D0.B8.D0.B9_.D0.B8_.D0.B4.D0.B0.D0.BB.D1.8C.D0.BD.D0.B8.D0.B9_.D1.80.D0.BE.D0.B4.D1.81.D1.82.D0.B2.D0.B5.D0.BD.D0.BD.D0.B8.D0.BA_.D0.90.D1.80.D0.BA.D0.B0.D0.BD.D0.BE.D0.B8.D0.B4.D0.B0">Описание проекта</a> на сайте Школы программиста.
		</div>
	</body>
</html>
